using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests.Objects;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Responses;
using JoyfulHomeJourney.BackEnd.Server.Instances;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
	public class VipsController : BaseController
	{
		private readonly IVipsServer _vipsServer;
		public VipsController(IVipsServer vipsServer)
		{
			_vipsServer = vipsServer;
		}
		/// <summary>
		/// 添加
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "carShop" })]
        public async Task<IActionResult> Add(RequestVipsDto dto)
		{
			dto.cid = _account.AId;
			return Send(await _vipsServer.AddAsync(dto));
		}
		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Delete(RequestVipsDto dto)
		{
			return Send(await _vipsServer.DeleteAsync(dto));
		}
		/// <summary>
		/// 获取VIP选择列表
		/// </summary>
		/// <returns></returns>
		[HttpGet]
        public async Task<IActionResult> GetSelect(string carShopId)
		{
			return Send(await _vipsServer.GetSelectAsync(carShopId));
		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Update(RequestVipsDto dto)
		{
			return Send(await _vipsServer.UpdateAsync(dto));
		}
        
        /// <summary>
		/// 查询VIP
		/// </summary>
		/// <returns></returns>
        [HttpGet]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "employee" })]
        public async Task<IActionResult> GetVip()
        {
			string uid=_account.AId;
            return Send(await _vipsServer.GetVip(uid));
        }
        /// <summary>
        /// PC获取所有vip用户
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "employee" })]
        public async Task<IActionResult> Getemploy_Vip(int page, int limit, string key)
        {
			string uid = _account.AId;
            return Send(await _vipsServer.Getemploy_Vip(page, limit, key, uid));
        }
        
        /// <summary>
        /// 查询VI （PcarShop）
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "carShop" })]
        public async Task<IActionResult> Get_Vip_carShop(int page, int limit, string key)
        {
			string uid = _account.AId;
            return Send(await _vipsServer.Get_Vip_carShop(page, limit, key,uid));
        }
        /// <summary>
        /// PC单个获取vip用户详细
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "employee" })]
        public async Task<IActionResult> Get_Vip_off(string id)
        {
            string uid = _account.AId;
            return Send(await _vipsServer.Get_Vip_off(id,uid));
        }
        /// <summary>
        /// 查询创建VIP订单
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "employee" })]
        public async Task<IActionResult> Get_Vip_offtrrezw(string vipId, string email)
        {
            string cid = _account.AId;
            return Send(await _vipsServer.Get_Vip_offtrrezw(vipId,cid, email));
        }
    }
}
